home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 25
/
Cream of the Crop 25.iso
/
os2
/
os2trace.zip
/
OS2TRACE.DOC
next >
Wrap
Text File
|
1997-05-20
|
34KB
|
641 lines
Operating System/2 API Trace Enabler/Customizer/Summarizer
Author : Dave Blaschke
IBM Austin, Texas
Internal (Notes) - Dave Blaschke@IBMUS
Internal (VM) - IBMUSM26(BLASCHKE)
External - blaschke@us.ibm.com
Description : Enables or disables the tracing of 16-bit and 32-bit OS/2
APIs imported by an executable file without affecting its
source code, and customizes and summarizes the tracing of
16-bit and 32-bit OS/2 APIs.
The first feat, trace enabling and disabling, is
accomplished by processing each entry in the table of
strings within the executable file that contains the names
of the imported DLLs. If the entry represents one of the
supported OS/2 DLLs and the user requested enablement of
API tracing for this DLL, the entry is replaced with the
name of the appropriate trace DLL. When the executable
file is invoked, the trace DLL intercepts API calls to its
corresponding OS/2 DLL, logs API input information, invokes
the API, and logs API output information. If the entry
represents one of the trace DLLs and the user requested
disablement of API tracing for this DLL, the entry is
replaced with the name of the supported OS/2 DLL. When
finished, the updated table of strings is written to the
executable file.
NOTE: All private APIs are simply forwarded to the
corresponding OS/2 DLL with no intervention from the trace
DLL.
The user can request enablement of API tracing by
specifying the -ON option or can request disablement of API
tracing by specifying the -OFF option. The user can
request enablement or disablement of API tracing for one or
more of the supported DLLs individually by specifying each
DLL's name as an option, or can request enablement or
disablement of API tracing for all supported DLLs by
specifying the -ALL option.
NOTE: Trace enablement alters the contents of the table of
strings within the executable file that contains the names
of the imported DLLs. Although this action does not affect
the functionality of the executable, it does affect its
date and time stamp.
The second feat, trace customizing, is accomplished by
storing the state of the trace customization options in the
operating system's user profile, OS2.INI. The state of
these options can then be retrieved by the trace DLLs when
a trace-enabled executable commences running.
The user can request to log a maximum number of bytes of
level 3 trace information from buffers by specifying the
-B n option, where n is a decimal number between 16 and
65536 (64KB), inclusive, and is rounded up to the nearest
multiple of 16. The user can request to log all level 3
trace information from buffers by specifying the -B ALL
option. The user can request to trace specific groups of
APIs from DOSCALLS.DLL by specifying the -D g option,
where g is ALL (request all API groups), one or more of the
following delimited by commas (request only specific API
groups), or ALL and one or more of the following each
prefixed by a "NO" and delimited by commas (request all
except specific API groups):
DEV indicates trace device API group
FILE indicates trace file API group
MEM indicates trace memory API group
MISC indicates trace miscellaneous API group
MOD indicates trace module API group
MVDM indicates trace MVDM API group
NLS indicates trace national language support API group
PIPE indicates trace pipe API group
PRF indicates trace performance API group
PROC indicates trace process and thread API group
RES indicates trace resource API group
SEM indicates trace semaphore API group
SES indicates trace session API group
TIME indicates trace date/time and timer API group
XCPT indicates trace exception API group
MSG indicates trace message API group
INFO indicates trace InfoSeg API group
SIG indicates trace signal API group
The user can request to log a maximum number of bytes of
trace information before log file wrapping (overwriting
from the beginning) occurs by specifying the -F n option,
where n is a decimal number between 4096 (4KB) and 67108864
(64MB), inclusive, and is rounded up to the nearest
multiple of 4096. The user can request to log all trace
information without log file wrapping by specifying the
-F ALL option.
NOTE: -F ALL appends trace information to the end of any
preexisting trace information file, while -F n erases the
contents of any preexisting trace information file.
The user can request to trace specific groups of APIs from
PMGPI.DLL by specifying the -G g option, where g is ALL
(request all API groups), one or more of the following
delimited by commas (request only specific API groups), or
ALL and one or more of the following each prefixed by a
"NO" and delimited by commas (request all except specific
API groups):
BIT indicates trace bitmap API group
CORR indicates trace correlation API group
CTRL indicates trace control API group
DEF indicates trace defaults API group
EDIT indicates trace segment editing API group
LCID indicates trace LCID API group
LCT indicates trace logical color table API group
META indicates trace metafile API group
PATH indicates trace path API group
POLY indicates trace polygon API group
PRIM indicates trace primitive API group
RGN indicates trace region API group
SEG indicates trace segment API group
TRAN indicates trace transform API group
DEV indicates trace device API group
The user can request to log specific levels of trace
information by specifying the -L n option, where n is one
of the following:
1 indicates log API entry/exit information
2 indicates log API parameters
3 indicates log API parameter contents
The user can request to enable time stamping of API entries
and exits by specifying the -T ON option. The user can
request to disable time stamping of API entries and exits
by specifying the -T OFF option.
NOTE: API entry time stamps reflect entry into the trace
API, not entry into the actual OS/2 API.
The user can request to trace specific groups of APIs from
PMWIN.DLL by specifying the -W g option, where g is ALL
(request all API groups), one or more of the following
delimited by commas (request only specific API groups), or
ALL and one or more of the following each prefixed by a
"NO" and delimited by commas (request all except specific
API groups):
ACCL indicates trace accelerator API group
ATOM indicates trace atom API group
CLIP indicates trace clipboard API group
CTRY indicates trace country API group
CUR indicates trace cursor API group
DDE indicates trace DDE API group
DESK indicates trace desktop API group
DLG indicates trace dialog API group
DWIN indicates trace WinDefWindowProc
ERR indicates trace error API group
FRAM indicates trace frame API group
HOOK indicates trace hook API group
INPT indicates trace input API group
LOAD indicates trace load API group
MENU indicates trace menu API group
MSG indicates trace message API group (does not include
MSGL group)
MSGL indicates trace WinDispatchMsg and WinGetMsg
PAL indicates trace palette API group
PTR indicates trace pointer API group
RECT indicates trace rectangle API group
SYS indicates trace system API group
THK indicates trace thunk API group
TIME indicates trace time API group
TREC indicates trace track rectangle API group
WIN indicates trace window API group (does not include
DWIN group)
NOTE: DWIN and MSGL are separated from WIN and MSG because
these APIs, when being traced, can severely impact the
performance of the trace-enabled executable.
The third feat, trace summarizing, is accomplished by
parsing the trace information file generated by a
trace-enabled executable and recording the number of API
entries and exits logged in the file. When finished, the
summary statistics are displayed in alphabetical order to
standard output.
The user can request to summarize the contents of a trace
information file by specifying the -S option.
The user can request helping information by specifying the
-?, -H, or -HELP option.
Installation : Place the executables, OS2TRACE.EXE and PMOS2TRC.EXE, in a
directory along the PATH, place the help file,
PMOS2TRC.HLP, in a directory along the HELP environment
variable, and place the trace DLLs, T_*.DLL, in a directory
along the LIBPATH.
Usage : Trace enabler -
OS2TRACE -OFF|-ON {-ALL|-dll}... file
Where:
-OFF indicates disable API tracing
-ON indicates enable API tracing
-ALL indicates enable/disable API tracing for all DLLs
-dll indicates enable/disable API tracing for specific
DLL, where dll can be one of the following:
DOSCALLS HELPMGR KBDCALLS MONCALLS MOUCALLS
MSG NAMPIPES NLS PMCTLS PMDRAG
PMGPI PMMERGE PMPIC PMSHAPI PMSPL
PMWIN PMWP QUECALLS SESMGR
file indicates name of executable file to be trace
enabled/disabled
NOTE: Trace enablement alters the contents of the
executable file's import module name table.
In the following example, tracing is enabled in TEST.EXE
for the APIs imported from QUECALLS and SESMGR:
OS2TRACE -ON -QUECALLS -SESMGR TEST.EXE
In the following example, tracing is disabled in TEST.EXE
for the APIs imported from all supported DLLs:
OS2TRACE -OFF -ALL TEST.EXE
Trace customizer -
OS2TRACE {-B n|-D g|-F n|-G g|-L n|-T f|-W g}...
Where:
-B n indicates log maximum of n bytes from buffers, where
16 ≤ n ≤ 65536 or n is ALL to indicate log all bytes
from buffers
-D g indicates trace specific DOSCALLS API groups, where
g is either ALL[,NOgrp]... or grp[,grp]... and grp
is one of the following:
DEV FILE MEM MISC MOD
MVDM NLS PIPE PRF PROC
RES SEM SES TIME XCPT
MSG INFO SIG
-F n indicates log maximum of n bytes before log file
wrapping occurs, where 4096 ≤ n ≤ 67108864 or n is
ALL to indicate log all information without log file
wrapping
-G g indicates trace specific PMGPI API groups, where
g is either ALL[,NOgrp]... or grp[,grp]... and grp
is one of the following:
BIT CORR CTRL DEF EDIT
LCID LCT META PATH POLY
PRIM RGN SEG TRAN DEV
INK
-L n indicates log level n information, where 1 ≤ n ≤ 3:
1 indicates log API entry/exit information
2 indicates log API parameters
3 indicates log API parameter contents
-T f indicates enable (f = ON) or disable (f = OFF) time
stamping of API entries and exits
-W g indicates trace specific PMWIN API groups, where
g is either ALL[,NOgrp]... or grp[,grp]... and grp
is one of the following:
ACCL ATOM CLIP CTRY CUR
DDE DESK DLG ERR FRAM
HOOK INPT LOAD MENU MSG
PAL PTR RECT SYS THK
TIME TREC WIN
NOTE: The default trace customization option settings are:
-B 256 -D ALL -F ALL -G ALL -L 1 -T OFF -W ALL
In the following example, tracing is customized to log
a maximum of 512 bytes of level 3 trace information from
buffers:
OS2TRACE -B 512
In the following example, tracing is customized to trace
only memory and semaphore API groups from DOSCALLS.DLL:
OS2TRACE -D MEM,SEM
In the following example, tracing is customized to log
a maximum of 16384 bytes of trace information before log
file wrapping occurs:
OS2TRACE -F 16384
In the following example, tracing is customized to trace
only bitmap, metafile, and transform API groups from
PMGPI.DLL:
OS2TRACE -G BIT,META,TRAN
In the following example, tracing is customized to log
level 2 information:
OS2TRACE -L 2
In the following example, tracing is customized to enable
time stamping of API entries/exits:
OS2TRACE -T ON
In the following example, tracing is customized to trace
all except hook and system API groups from PMWIN.DLL:
OS2TRACE -W ALL,NOHOOK,NOSYS
Trace summarizer -
OS2TRACE -S file
Where:
-S indicates summarize API tracing
file indicates name of trace information file to be trace
summarized
In the following example, tracing in TEST.TRC is summarized
and placed in TEST.SUM:
OS2TRACE -S TEST.TRC > TEST.SUM
Trace PM interface -
PMOS2TRC
Scenario : The following example shows a typical scenario where the
three personalities of OS2TRACE can be used in conjuction
to produce a summary of NLS APIs used by TEST.EXE:
OS2TRACE -D NLS -L 1
OS2TRACE -ON -DOSCALLS -NLS TEST.EXE
TEST
OS2TRACE -OFF -DOSCALLS -NLS TEST.EXE
OS2TRACE -S TEST.TRC > TEST.NLS
The first line customizes API tracing, the second line
enables API tracing, the third line invokes the executable,
which places all its API tracing information in TEST.TRC,
the fourth line disables API tracing, and the fifth line
summarizes API tracing.
The above example can also be performed completely within
the PM interface. The following starts the PM interface:
PMOS2TRC
The following then enables launching of .EXE files from the
PM interface:
1. Select Options/Launch .EXE files from main window
The following then sets the logging level to 1 (equivalent
to OS2TRACE -L 1):
2. Select Customize/Logging level... from main window
3. Click on Log API entry/exit (level 1) information button
4. Click on OK button to dismiss logging level dialog
The following then sets the DOSCALLS APIs group to NLS only
(equivalent to OS2TRACE -D NLS):
5. Select Customize/DOSCALLS APIs... from main window
6. Click on Clear button in DOSCALLS APIs dialog
7. Click on NLS button in same dialog
8. Click on OK button to dismiss DOSCALLS APIs dialog
The following then enables tracing of DOSCALLS and NLS DLLs
by TEST.EXE (equivalent to OS2TRACE -ON -DOSCALLS -NLS
TEST.EXE):
9. Select Enable/Open file... from main window
10. Enter TEST.EXE in entry field of open file dialog
11. Click on OK button to dismiss open file dialog
12. Click on All Off button in enablement dialog
13. Click on DOSCALLS "On" button in same dialog
14. Click on NLS "On" button in same dialog
15. Click on OK button to dismiss enablement dialog
At this point a dialog is presented for launching the .EXE
file. Because TEST.EXE requires no command line parameters
and can run in the foreground, the following then launches
TEST.EXE:
16. Click on OK button to dismiss launch dialog
After TEST.EXE has completed executing, the following then
disables tracing of all DLLs by TEST.EXE (equivalent to
OS2TRACE -OFF -ALL TEST.EXE):
17. Select Enable/Open file... from main window
18. Enter TEST.EXE in entry field of open file dialog
19. Click on OK button to dismiss open file dialog
20. Click on All Off button in enablement dialog
21. Click on OK button to dismiss enablement dialog
The following then summarizes API tracing logged in
TEST.TRC and places the results in TEST.NLS (equivalent to
OS2TRACE -S TEST.TRC > TEST.NLS):
22. Select Summarize/Open file... from main window
23. Enter TEST.TRC in entry field of open file dialog
24. Click on OK button to dismiss open file dialog
25. Click on Save As.. button in summarization dialog
26. Enter TEST.NLS in entry field of save file dialog
27. Click on OK button to dismiss save file dialog
28. Click on OK button to dismiss summarization dialog
Output : Trace enabler -
If the user requests enablement of API tracing (-ON
option), information similar to the following is displayed
for each requested DLL that is imported by the executable
file:
DLLNAME : File imports from DLL, API tracing enabled
information similar to the following is displayed for each
requested DLL whose trace DLL is already imported by the
executable file:
DLLNAME : File imports from trace DLL, API tracing already
enabled
information similar to the following is displayed for each
requested DLL that is not imported by the executable file:
DLLNAME : File does not import from DLL, API tracing not
enabled
information similar to the following is displayed for each
requested DLL that has an API name imported by the
executable file:
DLLNAME : File imports APINAME by name, API tracing cannot
be enabled
and information similar to the following is displayed for
each requested DLL that has an unsupported ordinal imported
by the executable file:
DLLNAME : File imports unsupported ordinal N, API tracing
cannot be enabled
If the user requests disablement of API tracing (-OFF
option), information similar to the following is displayed
for each requested trace DLL that is imported by the
executable file:
DLLNAME : File imports from trace DLL, API tracing disabled
information similar to the following is displayed for each
requested trace DLL whose DLL is already imported by the
executable file:
DLLNAME : File imports from DLL, API tracing already
disabled
and information similar to the following is displayed for
each requested trace DLL that is not imported by the
executable file:
DLLNAME : File does not import from trace DLL, API tracing
not disabled
Trace customizer -
If the user requests customization of API tracing (-B, -D,
-F, -G, -L, -T, and/or -W options), information similar to
the following is displayed:
Old trace customization options: -B 64 -D ALL -F ALL ...
New trace customization options: -B 256 -D SEM -F 65536 ...
The first line contains the state of the trace
customization options prior to the invocation of OS2TRACE
while the second line contains the state of the trace
customization options after the invocation of OS2TRACE.
Trace summarizer -
If the user requests summarization of the contents of a
trace information file (-S option), information similar to
the following is displayed:
Used APIs:
APINAME (4 Pass)
:
APINAME (12 Pass, 4 Fail, 2 No Return)
Each line contains the name of the used API, the number of
successful invocations, if any, the number of unsuccessful
invocations, if any, and the number of API entries without
matching exits (indicated by "No Return"), if any. It
should be noted that these APIs are listed in alphabetical
order.
Trace-enabled executable -
All levels of information, from the trace-enabled .EXE
and/or any trace-enabled .DLLs that are attached to the
.EXE, are logged to a text file with a file name that
matches the .EXE file name and an extension of .TRC. This
trace information file resides in the same directory as
the .EXE file. If another instance of the same .EXE is
already running, the file name of the text file is changed
to PROC followed by the hexadecimal process identifier
(i.e. PROC003A.TRC). If this occurs, a warning message is
issued.
NOTE: If a REXX program loads any trace-enabled .DLLs, all
trace information is logged to CMD.TRC in the same
directory as the CMD.EXE executable that loaded the REXX
program.
If the user requests level 1 information, data similar to
the following is logged for each API call:
003A 0001 | Dos32CreateQueue Entry
003A 0001 | Dos32CreateQueue Exit
PASS | Return code: 0
If the user requests level 2 information, data similar to
the following is logged for each API call:
003A 0001 | Dos32CreateQueue Entry
| Parameter 1: PHQUEUE = 0x00028BE8
| Parameter 2: ULONG = 0x00000002
| Parameter 3: PSZ = 0x000200A4
003A 0001 | Dos32CreateQueue Exit
PASS | Return code: 0
| Parameter 1: PHQUEUE = 0x00028BE8
If the user requests level 3 information, data similar to
to the following is logged for each API call:
003A 0001 | Dos32CreateQueue Entry, Return Address =...
| Parameter 1: PHQUEUE = 0x00028BE8
| Parameter 2: ULONG = 0x00000002
| Parameter 3: PSZ = 0x000200A4 ["\QUEUES\..."]
003A 0001 | Dos32CreateQueue Exit
PASS | Return code: 0 (NO_ERROR)
| Parameter 1: PHQUEUE = 0x00028BE8 [0x00000007]
The first number on both the API entry and exit lines is
the hexadecimal process identifier (PID) of the executable.
The second number is the hexadecimal thread identifier
(TID) of the thread within the executable that invoked the
API.
If the user requests level 3 information and a character,
ASCIIZ string, integer, color, FIXED, POINTL, or RECTL
buffer is larger than the maximum specified by the -B n
option, the data is truncated and -- More -- is logged.
If log file wrapping occurs, information similar to the
following is logged after the executable's stopping time,
OS2TRACE banner, and executable's starting time:
< Trace information lost due to log file wrapping 3 times >
All warning and error messages generated by the
trace-enabled executable are placed in the error message
file OS2TRACE.ERR in the root directory of the operating
system's boot drive in order to avoid conflicts with the
executable's output.
History : Version Date Item
2.30.00 12Jun95 Created (supported LX format and 32-bit Dos
APIs only)
2.30.01 09Jul95 Issued warning if trace DLL not on LIBPATH
2.30.02 18Jul95 Added optional "NO" prefix to API groups
2.30.03 20Jul95 Added 32-bit Win APIs
2.30.04 28Jul95 Fixed integer buffer logging
2.30.05 04Aug95 Added 32-bit Gpi APIs
2.30.06 09Aug95 Fixed Dos32DevIOCtl bug
2.30.07 11Aug95 Changed to new build structure
2.30.08 11Aug95 Added 32-bit Ddf APIs
2.30.09 12Aug95 Added 32-bit Dev APIs
2.30.10 13Aug95 Added 32-bit Drg APIs
2.30.11 14Aug95 Added 32-bit Prf APIs
2.30.12 25Aug95 Fixed Dos32QueryMessageCP bug
2.30.13 27Aug95 Added OS/2 for PowerPC support
2.30.14 29Aug95 Added 32-bit Prt and Spl APIs
2.30.15 29Aug95 Added 32-bit Pic APIs
2.30.16 22Sep95 Enhanced -B option
2.30.17 22Sep95 Added -F option
2.30.18 24Sep95 Added -T option
2.30.19 02Nov95 Fixed Drg32DragFiles bug
2.30.20 27Nov95 Added support for Dos APIs in MSG, NLS,
QUECALLS, and SESMGR exported by DOSCALL1
2.30.21 13Dec95 Forwarded private entry table ordinals
2.30.22 19Dec95 Added new 32-bit OS/2 3.00 non-Uni Dos APIs
2.30.23 27Mar96 Fixed PMWIN bugs
2.30.24 29Mar96 Added PM interface (supported customization
and help only)
2.30.25 15Apr96 Verified DOS header new header file address
2.30.26 23May96 Issued more specific enablement messages
2.30.27 13Jun96 Logged FEA2 structure EA value
2.30.28 14Jun96 Changed "\r\n" to "\n" in output
2.30.29 21Jun96 Fixed Dos32UnwindException bug
2.30.30 26Jun94 Added 32-bit OS/2 2.00 PM debugger APIs
2.40.00 05Sep96 Added new 32-bit OS/2 2.40 APIs
2.40.01 27Sep96 Fixed customization information display bug
2.40.02 11Mar97 Removed loading/unloading trace DLLs
2.40.03 11Mar97 Converted to IBM VisualAge C++
2.40.04 12Mar97 Fixed OS/2 for PowerPC DLL support
2.40.05 12Mar97 Added enablement support to PM interface
2.40.06 12Mar97 Fixed Win32EnumObjectClasses bug
2.40.07 13Mar97 Added customization cancel confirmation
2.40.08 13Mar97 Added summarization support to PM interface
2.40.09 14Mar97 Removed summarization API exit without
entry error
2.40.10 14Mar97 Fixed Dev32StdOpen bug
2.40.11 19Mar97 Added save window position option to PM
interface
2.40.12 19Mar97 Added support for NE format
2.40.13 20Mar97 Added launch .EXE files option to PM
interface
2.40.14 25Mar97 Fixed DENA2 buffer logging
2.40.15 01Apr97 Fixed Dos32FindFirst bug
2.40.16 15Apr97 Removed OS/2 for PowerPC from PM help
2.40.17 21Apr97 Added 16-bit Dos APIs
2.40.18 30Apr97 Added 16-bit Kbd APIs
2.40.19 01May97 Added 16-bit Mou APIs
2.40.20 05May97 Added 16-bit Vio APIs
2.40.21 20May97 Fixed/minimized 16-bit stack usage
Please direct all comments, problems, questions, and suggestions to the
author above.